﻿using System;
using System.Data;
using System.Collections;
using System.Text.RegularExpressions;
using System.Text;
using System.Web.Caching;

using LTJ.Common;
using LTJ.Data;
using LTJ.Config;
using LTJ.Entity;
using LTJ.Common.Generic;
using LTJ.Cache;

namespace LTJ.FrameWork
{
    /// <summary>
    /// 基础数据类型
    /// </summary>
    public class BaseTypes
    {
        /// <summary>
        /// 创建基础类型
        /// </summary>
        /// <param name="code">类型代码</param>
        /// <param name="tname">类型名称</param>
        /// <param name="ename">类型英文</param>
        /// <param name="extends">类型扩展</param>
        public static string CreateBaseType(string code, string tname, string ename, string extends)
        {
            if (GetBaseTypeCode(code) != null) return "";
            return Data.DataProvider.BaseTypes.CreateBaseType(code, tname, ename, extends);
        }
        
        /// <summary>
        /// 基础类型删除
        /// </summary>
        public static int DelBaseType(string bcode)
        {
            if (GetBaseDataByTypecode(bcode).Rows.Count != 0)
            {
                return -1;
            }
            else
            {
                return Data.DataProvider.BaseTypes.DelBaseType(bcode);
            }
        }
        /// <summary>
        /// 根据基础类型code查询是否有基础数据
        /// </summary>
        /// <param name="bcode"></param>
        public static DataTable GetBaseDataByTypecode(string bcode)
        {
            return Data.DataProvider.BaseTypes.GetBaseDataByTypecode(bcode);
        }

        /// <summary>
        /// 根据Code是否存在
        /// </summary>
        /// <param name="code"></param>
        public static BaseTypeInfo GetBaseTypeCode(string code)
        {
            return Data.DataProvider.BaseTypes.GetBaseTypeCode(code);
        }

        /// <summary>
        /// 基础类型分页
        /// </summary>
        /// <param name="pageindex"></param>
        /// <param name="pagesize"></param>
        /// <param name="condition"></param>
        /// <param name="orderstr"></param>
        public static DataTable GetBaseTypesByPage(int pageindex, int pagesize, string condition, string orderstr)
        {
            return Data.DataProvider.BaseTypes.GetBaseTypesByPage(pageindex, pagesize, condition, orderstr);
        }

        /// <summary>
        /// 基础类型数量
        /// </summary>
        /// <param name="conditions"></param>
        /// <returns></returns>
        public static int GetBaseTypeCount(string conditions)
        {
            return Data.DataProvider.BaseTypes.GetBaseTypeCount(conditions);
        }

        /// <summary>
        /// 修改基础类型信息
        /// </summary>
        /// <param name="code"></param>
        /// <param name="tname"></param>
        /// <param name="ename"></param>
        /// <param name="extends"></param>
        public static void UpdateBaseType(string code, string tname, string ename, string extends)
        {
            Data.DataProvider.BaseTypes.UpdateBaseType(code, tname, ename, extends);
        }
    }
}
